﻿using System.Globalization;
using System.Text.RegularExpressions;
using Azure;
using Newtonsoft.Json.Linq;
using SqlSugar;

namespace DataAcquisition
{

    #region 设备

    public class DeviceItem : AntdUI.NotifyProperty
    {
        public DeviceItem(int number, string name, int address, string port, int baudRate)
        {
            _Number = number;
            _Name = name;
            _Address = address;
            _Port = port;
            _BaudRate = baudRate;
            _Operation = new AntdUI.CellLink[] {
                        //new AntdUI.CellButton("edit") { BorderWidth=1, IconSvg="EditOutlined"},
                        new AntdUI.CellButton("point") { BorderWidth=1, IconSvg="ApartmentOutlined"},
                        new AntdUI.CellButton("delete") { BorderWidth=1, IconSvg="DeleteOutlined"},
        };
        }

        int _Number;
        public int Number
        {
            get => _Number;
            set
            {
                if (_Number == value) return;
                _Number = value;
                OnPropertyChanged("Number");
            }
        }

        string _Name;
        public string Name
        {
            get => _Name;
            set
            {
                if (_Name == value) return;
                _Name = value;
                OnPropertyChanged("Name");
            }
        }

        int _Address;
        public int Address
        {
            get => _Address;
            set
            {
                if (_Address == value) return;
                _Address = value;
                OnPropertyChanged("Address");
            }
        }

        string _Port;
        public string Port
        {
            get => _Port;
            set
            {
                if (_Port == value) return;
                _Port = value;
                OnPropertyChanged("Port");
            }
        }

        int _BaudRate;
        public int BaudRate
        {
            get => _BaudRate;
            set
            {
                if (_BaudRate == value) return;
                _BaudRate = value;
                OnPropertyChanged("baudRate");
            }
        }

        int _DIPointCount;
        public int DIPointCount
        {
            get => _DIPointCount;
            set
            {
                if (_DIPointCount == value) return;
                _DIPointCount = value;
                OnPropertyChanged("DIPointCount");
            }
        }

        int _DOPointCount;
        public int DOPointCount
        {
            get => _DOPointCount;
            set
            {
                if (_DOPointCount == value) return;
                _DOPointCount = value;
                OnPropertyChanged("DOPointCount");
            }
        }

        int _InputPointCount;
        public int InputPointCount
        {
            get => _InputPointCount;
            set
            {
                if (_InputPointCount == value) return;
                _InputPointCount = value;
                OnPropertyChanged("InputPointCount");
            }
        }

        int _HoldingPointCount;
        public int HoldingPointCount
        {
            get => _HoldingPointCount;
            set
            {
                if (_HoldingPointCount == value) return;
                _HoldingPointCount = value;
                OnPropertyChanged("HoldingPointCount");
            }
        }

        AntdUI.CellLink[] _Operation;
        public AntdUI.CellLink[] Operation
        {


            get => _Operation;
            set
            {
                _Operation = value;
                OnPropertyChanged("Operation");
            }
        }
    }

    /// <summary>
    /// 设备
    ///</summary>
    [SugarTable("d_device")]

    public class Device
    {
        /// <summary>
        /// 备  注:编号
        ///</summary>
        [SugarColumn(ColumnName = "number", IsPrimaryKey = true)]
        public int Number { get; set; }

        /// <summary>
        /// 备  注:名称
        ///</summary>
        [SugarColumn(ColumnName = "name")]
        public string Name { get; set; } = null!;

        /// <summary>
        /// 备  注:地址
        ///</summary>
        [SugarColumn(ColumnName = "address")]
        public int Address { get; set; }

        /// <summary>
        /// 备  注:串口
        ///</summary>
        [SugarColumn(ColumnName = "port")]
        public string Port { get; set; } = null!;

        /// <summary>
        /// 备  注:波特率
        ///</summary>
        [SugarColumn(ColumnName = "baud_rate")]
        public int BaudRate { get; set; }

        /// <summary>
        /// 备  注:DI点数量
        ///</summary>
        [SugarColumn(ColumnName = "di_point_count")]
        public int DIPointCount { get; set; }

        /// <summary>
        /// 备  注:DO点数量
        ///</summary>
        [SugarColumn(ColumnName = "do_point_count")]
        public int DOPointCount { get; set; }

        /// <summary>
        /// 备  注:input点数量
        ///</summary>
        [SugarColumn(ColumnName = "input_point_count")]
        public int InputPointCount { get; set; }

        /// <summary>
        /// 备  注:holding点数量
        ///</summary>
        [SugarColumn(ColumnName = "holding_point_count")]
        public int HoldingPointCount { get; set; }
    }
    #endregion

    #region 设备点位
    /// <summary>
    /// 设备点位
    ///</summary>
    [SugarTable("d_device_point")]
    public class DevicePoint
    {
        /// <summary>
        /// 备  注:点位编号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "number", IsPrimaryKey = true)]
        public int Number { get; set; }

        /// <summary>
        /// 备  注:点位名称
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "name")]
        public string Name { get; set; } = null!;

        /// <summary>
        /// 备  注:点位地址
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "address")]
        public int Address { get; set; }

        /// <summary>
        /// 备  注:点位类型1->DI 2->DO 3->Input 4->Holding
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "point_type")]
        public int PointType { get; set; }

        /// <summary>
        /// 备  注:最小量程
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "range_min")]
        public double RangeMin { get; set; }

        /// <summary>
        /// 备  注:量程最大
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "range_max")]
        public double RangeMax { get; set; }

        /// <summary>
        /// 备  注:输出最小
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "out_min")]
        public double OutMin { get; set; }

        /// <summary>
        /// 备  注:输出最大
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "out_max")]
        public double OutMax { get; set; }

        /// <summary>
        /// 备  注:修正值
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "amend")]
        public double Amend { get; set; }

        /// <summary>
        /// 备  注:报警最低
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "alarm_low")]
        public double AlarmLow { get; set; }

        /// <summary>
        /// 备  注:报警最高
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "alarm_hight")]
        public double AlarmHight { get; set; }

        /// <summary>
        /// 备  注:误差范围
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "error_range")]
        public double ErrorRange { get; set; }

        /// <summary>
        /// 备  注:单位
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "unit")]
        public string Unit { get; set; } = null!;

        /// <summary>
        /// 备  注:设备编码
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "device_number")]
        public int DeviceNumber { get; set; }

        /// <summary>
        /// 备  注:设备名称
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "device_name")]
        public string DeviceName { get; set; } = null!;

        /// <summary>
        /// 备  注:设备地址
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "device_address")]
        public int DeviceAddress { get; set; }
    }

    public class DevicePointItem : AntdUI.NotifyProperty
    {
        public DevicePointItem(int deviceNumber, string deviceName,
                               int number, string name,
                               int address, int pointType, string range,
                               string outValue, string alarm, string errorRange,
                               double amend,
                               string unit
                               )
        {
            _DeviceNumber = deviceNumber;
            _DeviceName = deviceName;
            _Number = number;
            _Name = name;
            _Address = address;
            _PointType = pointType;
            if (pointType == 3 || pointType == 4)
            {
                _Range = range;
                _OutValue = outValue;
                _Alarm = alarm;
                _ErrorRange = errorRange;
                _Unit = unit;
                NumberFormatInfo nfi3_1 = new NumberFormatInfo();
                _Amend = amend.ToString("N", nfi3_1);
            }
            else
            {
                _Range = "--";
                _OutValue = "--"; ;
                _Alarm = "--";
                _ErrorRange = "--";
                _Unit = "--";
                _Amend = "--";
            }
            _Operation = new AntdUI.CellLink[] {
                        //new AntdUI.CellButton("edit") { BorderWidth=1, IconSvg="EditOutlined"},
                        new AntdUI.CellButton("delete") { BorderWidth=1, IconSvg="DeleteOutlined"},
        };
        }

        int _DeviceNumber;
        public int DeviceNumber
        {
            get => _DeviceNumber;
            set
            {
                if (_DeviceNumber == value) return;
                _DeviceNumber = value;
                OnPropertyChanged("DeviceNumber");
            }
        }

        string _DeviceName = string.Empty;
        public string DeviceName
        {
            get => _DeviceName;
            set
            {
                if (_DeviceName == value) return;
                _DeviceName = value;
                OnPropertyChanged("DeviceName");
            }
        }

        int _DeviceAddress;
        public int DeviceAddress
        {
            get => _DeviceAddress;
            set
            {
                if (_DeviceAddress == value) return;
                _DeviceAddress = value;
                OnPropertyChanged("DeviceAddress");
            }
        }

        int _Number;
        public int Number
        {
            get => _Number;
            set
            {
                if (_Number == value) return;
                _Number = value;
                OnPropertyChanged("Number");
            }
        }

        string _Name = string.Empty;
        public string Name
        {
            get => _Name;
            set
            {
                if (_Name == value) return;
                _Name = value;
                OnPropertyChanged("Name");
            }
        }

        int _Address;
        public int Address
        {
            get => _Address;
            set
            {
                if (_Address == value) return;
                _Address = value;
                OnPropertyChanged("Address");
            }
        }

        int _PointType;
        public int PointType
        {
            get => _PointType;
            set
            {
                if (_PointType == value) return;
                _PointType = value;
                OnPropertyChanged("PointType");
            }
        }

        string _Range = string.Empty;
        public string Range
        {
            get => _Range;
            set
            {
                if (_Range == value) return;
                _Range = value;
                OnPropertyChanged("Range");
            }
        }

        string _OutValue = string.Empty;
        public string OutValue
        {
            get => _OutValue;
            set
            {
                if (_OutValue == value) return;
                _OutValue = value;
                OnPropertyChanged("OutValue");
            }
        }

        string _Alarm = string.Empty;
        public string Alarm
        {
            get => _Alarm;
            set
            {
                if (_Alarm == value) return;
                _Alarm = value;
                OnPropertyChanged("Alarm");
            }
        }

        string _ErrorRange = string.Empty;
        public string ErrorRange
        {
            get => _ErrorRange;
            set
            {
                if (_ErrorRange == value) return;
                _ErrorRange = value;
                OnPropertyChanged("ErrorRange");
            }
        }

        string _Amend;
        public string Amend
        {
            get => _Amend;
            set
            {
                if (_Amend == value) return;
                _Amend = value;
                OnPropertyChanged("Amend");
            }
        }

        string _Unit = string.Empty;
        public string Unit
        {
            get => _Unit;
            set
            {
                if (_Unit == value) return;
                _Unit = value;
                OnPropertyChanged("Unit");
            }
        }

        AntdUI.CellLink[] _Operation;
        public AntdUI.CellLink[] Operation
        {
            get => _Operation;
            set
            {
                _Operation = value;
                OnPropertyChanged("Operation");
            }
        }
    }
    #endregion

    #region 界面点位

    public class FormPointItem : AntdUI.NotifyProperty
    {

        public FormPointItem(int number,
                             string name,
                             int devicePointNumber,
                             string devicePointName)
        {
            _Number = number;
            _Name = name;
            _DevicePointNumber = devicePointNumber;
            _DevicePointName = devicePointName;
            _Operation = new AntdUI.CellLink[] {
                        //new AntdUI.CellButton("edit") { BorderWidth=1, IconSvg="EditOutlined"},
                        new AntdUI.CellButton("delete") { BorderWidth=1, IconSvg="DeleteOutlined"} };
        }

        int _Number;
        public int Number
        {
            get => _Number;
            set
            {
                if (_Number == value) return;
                _Number = value;
                OnPropertyChanged("Number");
            }
        }

        string _Name = string.Empty;
        public string Name
        {
            get => _Name;
            set
            {
                if (_Name == value) return;
                _Name = value;
                OnPropertyChanged("Name");
            }
        }

        int _DevicePointNumber;
        public int DevicePointNumber
        {
            get => _DevicePointNumber;
            set
            {
                if (_DevicePointNumber == value) return;
                _DevicePointNumber = value;
                OnPropertyChanged("DevicePointNumber");
            }
        }

        string _DevicePointName = string.Empty;
        public string DevicePointName
        {
            get => _DevicePointName;
            set
            {
                if (_DevicePointName == value) return;
                _DevicePointName = value;
                OnPropertyChanged("DevicePointName");
            }
        }

        AntdUI.CellLink[] _Operation;
        public AntdUI.CellLink[] Operation
        {
            get => _Operation;
            set
            {
                _Operation = value;
                OnPropertyChanged("Operation");
            }
        }
    }

    /// <summary>
    /// 界面点位
    ///</summary>
    [SugarTable("d_form_point")]
    public class FormPoint
    {
        /// <summary>
        /// 备  注:界面点位编号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "number", IsPrimaryKey = true)]
        public int Number { get; set; }

        /// <summary>
        /// 备  注:界面点位名称
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "name")]
        public string Name { get; set; } = null!;

        /// <summary>
        /// 备  注:设备点位编号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "device_point_number")]
        public int DevicePointNumber { get; set; }

        /// <summary>
        /// 备  注:设备点位名称
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "device_point_name")]
        public string DevicePointName { get; set; } = null!;


    }
    #endregion

    #region 试压模板
    /// <summary>
    /// 试压模板
    ///</summary>
    [SugarTable("d_template")]
    public class Template
    {
        /// <summary>
        /// 备  注:ID
        ///</summary>
        [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
        public int ID { get; set; }

        /// <summary>
        /// 备  注:编号
        ///</summary>
        [SugarColumn(ColumnName = "number", IsPrimaryKey = true)]
        public int Number { get; set; }

        /// <summary>
        /// 备  注:管道位置
        ///</summary>
        [SugarColumn(ColumnName = "pipe_position")]
        public string PipePosition { get; set; } = null!;

        /// <summary>
        /// 备  注:设计压力
        ///</summary>
        [SugarColumn(ColumnName = "design_pressure")]
        public double DesignPressure { get; set; }

        //-----------------------------------------------------------------

        /// <summary>
        /// 备  注:阶段一压力
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_pressure")]
        public double FirstStagePressure { get; set; }

        /// <summary>
        /// 备  注:阶段一持续时间
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_time")]
        public int FirstStageTime { get; set; }

        /// <summary>
        /// 备  注:阶段一持续时间单位：小时、分钟
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_time_unit")]
        public string FirstStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:阶段一判断方式 0：固定数值 1：浮动范围
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_estimate_way")]
        public int FirstStageEstimateWay { get; set; }

        /// <summary>
        /// 备  注:阶段一判断值
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_estimate_value")]
        public double FirstStageEstimateValue { get; set; }

        //-----------------------------------------------------------------

        /// <summary>
        /// 备  注:阶段二压力
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_pressure")]
        public double SecondStagePressure { get; set; }

        /// <summary>
        /// 备  注:阶段二持续时间
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_time")]
        public int SecondStageTime { get; set; }

        /// <summary>
        /// 备  注:阶段二持续时间单位：小时、分钟
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_time_unit")]
        public string SecondStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:阶段二判断方式 0：固定数值 1：浮动范围
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_estimate_way")]
        public int SecondStageEstimateWay { get; set; }

        /// <summary>
        /// 备  注:阶段二判断值
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_estimate_value")]
        public double SecondStageEstimateValue { get; set; }

        //-----------------------------------------------------------------

        /// <summary>
        /// 备  注:阶段三压力
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_pressure")]
        public double ThirdStagePressure { get; set; }

        /// <summary>
        /// 备  注:阶段三持续时间
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_time")]
        public int ThirdStageTime { get; set; }

        /// <summary>
        /// 备  注:阶段三持续时间单位：小时、分钟
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_time_unit")]
        public string ThirdStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:阶段三判断方式 0：固定数值 1：浮动范围
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_estimate_way")]
        public int ThirdStageEstimateWay { get; set; }

        /// <summary>
        /// 备  注:阶段三判断值
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_estimate_value")]
        public double ThirdStageEstimateValue { get; set; }

        //-----------------------------------------------------------------

        /// <summary>
        /// 备  注:强度阶段压力
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_pressure")]
        public double IntensityStagePressure { get; set; }

        /// <summary>
        /// 备  注:强度阶段持续时间
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_time")]
        public int IntensityStageTime { get; set; }

        /// <summary>
        /// 备  注:强度阶段持续时间单位：小时、分钟
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_time_unit")]
        public string IntensityStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:强度阶段判断方式 0：固定数值 1：浮动范围
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_estimate_way")]
        public int IntensityStageEstimateWay { get; set; }

        /// <summary>
        /// 备  注:强度阶段判断值
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_estimate_value")]
        public double IntensityStageEstimateValue { get; set; }

        //-----------------------------------------------------------------

        /// <summary>
        /// 备  注:严密阶段压力
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_pressure")]
        public double RigorStagePressure { get; set; }

        /// <summary>
        /// 备  注:严密阶段持续时间
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_time")]
        public int RigorStageTime { get; set; }

        /// <summary>
        /// 备  注:严密阶段持续时间单位：小时、分钟
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_time_unit")]
        public string RigorStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:严密阶段判断方式 0：固定数值 1：浮动范围
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_estimate_way")]
        public int RigorStageEstimateWay { get; set; }

        /// <summary>
        /// 备  注:严密阶段判断值
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_estimate_value")]
        public double RigorStageEstimateValue { get; set; }

        /// <summary>
        /// 备  注:试压阶段数量
        ///</summary>
        [SugarColumn(ColumnName = "stage_count")]
        public int StageCount { get; set; }
    }

    public class TemplateItem : AntdUI.NotifyProperty
    {
        public TemplateItem(int id, int number, string pipePosition,
                       double designPressure,
                       string firstStage,
                       string secondStage,
                       string thirdStage,
                       string intensityStage,
                       string rigorStage
                       )
        {
            _ID = id;
            _Number = number;
            _PipePosition = pipePosition;
            _DesignPressure = designPressure;
            _FirstStage = firstStage.Length > 0 ? firstStage : "--";
            _SecondStage = secondStage.Length > 0 ? secondStage : "--";
            _ThirdStage = thirdStage.Length > 0 ? thirdStage : "--";
            _IntensityStage = intensityStage.Length > 0 ? intensityStage : "--";
            _RigorStage = rigorStage.Length > 0 ? rigorStage : "--";
            _Operation = new AntdUI.CellLink[] {
                       // new AntdUI.CellButton("edit") { BorderWidth=1, IconSvg="EditOutlined"},
                        new AntdUI.CellButton("delete") { BorderWidth=1, IconSvg="DeleteOutlined"},
            };
        }

        #region 属性

        int _ID;
        public int ID
        {
            get => _ID;
            set
            {
                if (_ID == value) return;
                _ID = value;
                OnPropertyChanged("ID");
            }
        }

        int _Number;
        public int Number
        {
            get => _Number;
            set
            {
                if (_Number == value) return;
                _Number = value;
                OnPropertyChanged("Number");
            }
        }

        string _PipePosition = string.Empty;
        public string PipePosition
        {
            get => _PipePosition;
            set
            {
                if (_PipePosition == value) return;
                _PipePosition = value;
                OnPropertyChanged("PipePosition ");
            }
        }

        double _DesignPressure;
        public double DesignPressure
        {
            get => _DesignPressure;
            set
            {
                if (_DesignPressure == value) return;
                _DesignPressure = value;
                OnPropertyChanged("DesignPressure");
            }
        }

        string _FirstStage = string.Empty;
        public string FirstStage
        {
            get => _FirstStage;
            set
            {
                if (_FirstStage == value) return;
                _FirstStage = value;
                OnPropertyChanged("FirstStage ");
            }
        }

        string _SecondStage = string.Empty;
        public string SecondStage
        {
            get => _SecondStage;
            set
            {
                if (_SecondStage == value) return;
                _SecondStage = value;
                OnPropertyChanged("SecondStage ");
            }
        }

        string _ThirdStage = string.Empty;
        public string ThirdStage
        {
            get => _ThirdStage;
            set
            {
                if (_ThirdStage == value) return;
                _ThirdStage = value;
                OnPropertyChanged("ThirdStage ");
            }
        }

        string _IntensityStage = string.Empty;
        public string IntensityStage
        {
            get => _IntensityStage;
            set
            {
                if (_IntensityStage == value) return;
                _IntensityStage = value;
                OnPropertyChanged("IntensityStage ");
            }
        }

        string _RigorStage = string.Empty;
        public string RigorStage
        {
            get => _RigorStage;
            set
            {
                if (_RigorStage == value) return;
                _RigorStage = value;
                OnPropertyChanged("RigorStage ");
            }
        }

        AntdUI.CellLink[] _Operation = new AntdUI.CellLink[] { };
        public AntdUI.CellLink[] Operation
        {
            get => _Operation;
            set
            {
                _Operation = value;
                OnPropertyChanged("Operation");
            }
        }
        #endregion
    }
    #endregion

    #region 试压工程
    /// <summary>
    /// 试压工程
    ///</summary>
    [SugarTable("d_project")]
    public class Project
    {
        /// <summary>
        /// 备  注:ID
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
        public int ID { get; set; }

        /// <summary>
        /// 备  注:工程编号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "number", IsPrimaryKey = true)]
        public string Number { get; set; } = null!;

        /// <summary>
        /// 备  注:工程名称
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "name")]
        public string Name { get; set; } = null!;

        /// <summary>
        /// 备  注:工程桩号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "stake_mark")]
        public string StakeMark { get; set; } = null!;

        /// <summary>
        /// 备  注:管材规格
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "pipe_specification")]
        public string PipeSpecification { get; set; } = null!;

        /// <summary>
        /// 备  注:管道长度
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "pipe_length")]
        public double PipeLength { get; set; }

        /// <summary>
        /// 备  注:试压介质
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "medium")]
        public string Medium { get; set; } = null!;

        /// <summary>
        /// 备  注:设计压力
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "design_pressure")]
        public double DesignPressure { get; set; }

        /// <summary>
        /// 备  注:管道性质
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "pipe_nature")]
        public string PipeNature { get; set; } = null!;

        /// <summary>
        /// 备  注:试压类型
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "test_type")]
        public string TestType { get; set; } = null!;

        /// <summary>
        /// 备  注:施工单位
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "company")]
        public string Company { get; set; } = null!;

        /// <summary>
        /// 备  注:压力表精度
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "manometer_precision")]
        public string ManometerPrecision { get; set; } = null!;

        /// <summary>
        /// 备  注:压力表量程
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "manometer_range")]
        public string ManometerRange { get; set; } = null!;

        /// <summary>
        /// 备  注:试压模板ID
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "template_id")]
        public int TemplateID { get; set; }
    }
    public class ProjectItem : AntdUI.NotifyProperty
    {

        public ProjectItem(
                           int id,
                           string number,
                           string name,
                           string stakeMark,
                           string pipeSpecification,
                           double pipeLength,
                           string medium,
                           double designPressure,
                           string pipeNature,
                           string testType,
                           string company,
                           string manometerPrecision,
                           string manometerRange,
                           int templateID
            )
        {
            _ID = id;
            _Number = number;
            _Name = name;
            _StakeMark = stakeMark;
            _PipeSpecification = pipeSpecification;
            _PipeLength = pipeLength;
            _Medium = medium;
            _DesignPressure = designPressure;
            _PipeNature = pipeNature;
            _Testtype = testType;
            _Company = company;
            _ManometerPrecision = manometerPrecision;
            _ManometerRange = manometerRange;
            _TemplateID = templateID;
            _Operation = new AntdUI.CellLink[] {
                        //new AntdUI.CellButton("edit") { BorderWidth=1, IconSvg="EditOutlined"},
                        new AntdUI.CellButton("delete") { BorderWidth=1, IconSvg="DeleteOutlined"} };
        }
        #region 属性

        int _ID;
        public int ID
        {
            get => _ID;
            set
            {
                if (_ID == value) return;
                _ID = value;
                OnPropertyChanged("ID");
            }
        }

        string _Number = string.Empty;
        public string Number
        {
            get => _Number;
            set
            {
                if (_Number == value) return;
                _Number = value;
                OnPropertyChanged("Number");
            }
        }

        string _Name = string.Empty;
        public string Name
        {
            get => _Name;
            set
            {
                if (_Name == value) return;
                _Name = value;
                OnPropertyChanged("Name");
            }
        }

        string _StakeMark = string.Empty;
        public string StakeMark
        {
            get => _StakeMark;
            set
            {
                if (_StakeMark == value) return;
                _StakeMark = value;
                OnPropertyChanged("StakeMark");
            }
        }

        string _PipeSpecification = string.Empty;
        public string PipeSpecification
        {
            get => _PipeSpecification;
            set
            {
                if (_PipeSpecification == value) return;
                _PipeSpecification = value;
                OnPropertyChanged("PipeSpecification");
            }
        }

        double _PipeLength;
        public double PipeLength
        {
            get => _PipeLength;
            set
            {
                if (_PipeLength == value) return;
                _PipeLength = value;
                OnPropertyChanged("PipeLength");
            }
        }

        string _Medium = string.Empty;
        public string Medium
        {
            get => _Medium;
            set
            {
                if (_Medium == value) return;
                _Medium = value;
                OnPropertyChanged("Medium");
            }
        }

        double _DesignPressure;
        public double DesignPressure
        {
            get => _DesignPressure;
            set
            {
                if (_DesignPressure == value) return;
                _DesignPressure = value;
                OnPropertyChanged("DesignPressure");
            }
        }

        string _PipeNature = string.Empty;
        public string PipeNature
        {
            get => _PipeNature;
            set
            {
                if (_PipeNature == value) return;
                _PipeNature = value;
                OnPropertyChanged("PipeNature");
            }
        }

        string _Testtype = string.Empty;
        public string Testtype
        {
            get => _Testtype;
            set
            {
                if (_Testtype == value) return;
                _Testtype = value;
                OnPropertyChanged("Testtype");
            }
        }

        string _Company = string.Empty;
        public string Company
        {
            get => _Company;
            set
            {
                if (_Company == value) return;
                _Company = value;
                OnPropertyChanged("Company");
            }
        }

        string _ManometerPrecision = string.Empty;
        public string ManometerPrecision
        {
            get => _ManometerPrecision;
            set
            {
                if (_ManometerPrecision == value) return;
                _ManometerPrecision = value;
                OnPropertyChanged("ManometerPrecision");
            }
        }

        string _ManometerRange = string.Empty;
        public string ManometerRange
        {
            get => _ManometerRange;
            set
            {
                if (_ManometerRange == value) return;
                _ManometerRange = value;
                OnPropertyChanged("ManometerRange");
            }
        }

        int _TemplateID;
        public int TemplateID
        {
            get => _TemplateID;
            set
            {
                if (_TemplateID == value) return;
                _TemplateID = value;
                OnPropertyChanged("TemplateID");
            }
        }

        AntdUI.CellLink[] _Operation = new AntdUI.CellLink[] { };
        public AntdUI.CellLink[] Operation
        {
            get => _Operation;
            set
            {
                _Operation = value;
                OnPropertyChanged("Operation");
            }
        }

        #endregion
    }
    #endregion

    #region 试压记录

    /// <summary>
    /// 试压工程
    ///</summary>
    [SugarTable("d_test_record")]
    public class TestRecord
    {
        /// <summary>
        /// 备  注:记录编号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "number", IsPrimaryKey = true)]
        public int number { get; set; }

        /// <summary>
        /// 备  注:开始时间
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "start_time")]
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 备  注:结束时间
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "end_time")]
        public DateTime EndTime { get; set; }

        /// <summary>
        /// 备  注:项目ID
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "project_id")]
        public int Project_ID { get; set; }
    }
    #endregion

    /// <summary>
    /// 数据点位
    ///</summary>
    [SugarTable("d_data_point")]
    public class DataPoint
    {
        /// <summary>
        /// 备  注:试压记录编号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "test_record_number")]
        public int test_record_number { get; set; }

        /// <summary>
        /// 备  注:时间
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "time")]
        public DateTime time { get; set; }

        /// <summary>
        /// 备  注:
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "main_pressure")]
        public double main_pressure { get; set; }

        /// <summary>
        /// 备  注:
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "enviroment_templature")]
        public double enviroment_templature { get; set; }

        /// <summary>
        /// 备  注:
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "main_medium_templature")]
        public double main_medium_templature { get; set; }

        /// <summary>
        /// 备  注:
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "main_machine_templature")]
        public double main_machine_templature { get; set; }

        /// <summary>
        /// 备  注:
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "remote_pressure")]
        public double remote_pressure { get; set; }

        /// <summary>
        /// 备  注:
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "remote_medium_templature")]
        public double remote_medium_templature { get; set; }

        /// <summary>
        /// 备  注:
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "remote_machine_templature")]
        public double remote_machine_templature { get; set; }


    }
}
